package com.acoffee.maven.service.impl;

import com.acoffee.maven.bean.UserVo;
import com.acoffee.maven.mapper.UserMapper;
import com.acoffee.maven.pojo.User;
import com.acoffee.maven.service.UserService;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author acoffee
 * @create 2021-05-11 19:59
 */
@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User login(String telephone, String password) {
        return userMapper.selectUserByTelephone(telephone,password);
    }

    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    @Override
    public List<User> findUserByPage(UserVo userVo) {
        PageHelper.startPage(userVo.getPageSize(),userVo.getCount());
        return this.userMapper.selectUsersByUser(userVo);
    }

    @Override
    public void addUser(User user) {
        this.userMapper.insertUser(user);
    }
}
